import { PageReq, PageRes } from '@/api/types'
import request from '@/utils/request'
import { BorrowModel } from '@/api/model/borrow-model'

// 获取借用列表
export function borrowPageApi(data: PageReq<Partial<any>>) {
  return request<PageRes<any>>({
    url: '/borrow/page',
    method: 'post',
    data
  })
}

// 新增借用
export function addBorrowApi(data: Partial<BorrowModel>) {
  return request({
    url: '/borrow/add',
    method: 'post',
    data
  })
}

// 更新借用
export function editBorrowApi(data: Partial<BorrowModel & { id: number }>) {
  return request({
    url: '/borrow/edit',
    method: 'post',
    data
  })
}

// 删除借用
export function delBorrowApi(data: { id: number }) {
  return request({
    url: '/borrow/del',
    method: 'post',
    data
  })
}

// 获取借用列表
export function getBorrowListApi(data: { isInStore: boolean }) {
  return request({
    url: '/borrow/getBorrowList',
    method: 'post',
    data
  })
}

// 获取借用详情
export function getBorrowDetailApi(data: { id: number }) {
  return request({
    url: '/borrow/getBorrowDetail',
    method: 'post',
    data
  })
}
